<template>
	<view>
		<view class="uni-list" style="margin-bottom: 160rpx;">
			<view style="background: #FFFFFF;justify-content: center;align-items: center;" v-for="(item, index) in items" :key="item.etpId">
				<view class="row-css" style="border-bottom: 1rpx solid #EEEEEE;padding: 30rpx 0;margin: 0 20rpx;align-items: center;" @click="onCarry(item)">
					{{ item.etpName}}
					<view
						v-if="item.state == 1 && item.loadingOrderCount > 0"
						style="border-radius: 50%;width: 30rpx;height: 30rpx;line-height: 30rpx;text-align: center;color: #FFFFFF; background: #F36363;"
					>
						{{ item.loadingOrderCount }}
					</view>
					<view
						v-if="item.state == 0"
						style="background: #FB8536;border-radius: 50rpx;color: #FFFFFF;font-size: 18rpx;text-align: center;padding: 3rpx 10rpx;margin: 5rpx 10rpx;"
					>
						待审核
					</view>
				</view>
			</view>
			<view class="position-fixed" @click="addcarrier">+ 加入新承运企业</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			items: [],
			current: 0
		};
	},
	methods: {
		radioChange: function(evt) {
			for (let i = 0; i < this.items.length; i++) {
				if (this.items[i].etpName=== evt.target.value) {
					this.current = i;
					break;
				}
			}
		},
		addcarrier() {
			uni.navigateTo({
				url: '../task/joincarrier'
			});
		},
		onCarry: function(vaues) {
			console.log("dddddd============",vaues.etpId);
			console.log("dddddd============",vaues.state != 0);
			if (vaues.state != 0) {
				uni.setStorageSync(this.DATA_KEY.etpId, vaues.etpId);
				uni.setStorageSync(this.DATA_KEY.etpName, vaues.etpName);
				uni.navigateBack({
					delta: 1
				});
			}
		},
		onmyCorp() {
			this.wxRequest({
				url: `${this.API}/driverService/getEtpList?is_enable=1&driver_id=`+uni.getStorageSync(this.DATA_KEY.userInfo).driverId,
				method: 'POST',
				success: res => {
					this.items = res.data.data.list;
				}
			});
		}
	},
	onShow() {
		this.onmyCorp();
	},
	onLoad() {
		this.onmyCorp();
	}
};
</script>

<style>
.row-css {
	display: flex;
	flex-direction: row;
}

.column-css {
	display: flex;
	flex-direction: column;
}

.position-fixed {
	background: #007aff;
	display: flex;
	position: fixed;
	bottom: 20rpx;
	justify-content: center;
	border-radius: 10rpx;
	color: #ffffff;
	padding: 20rpx;
	margin: 40rpx;
	width: 84%;
	font-size: 24rpx;
}
</style>
